page.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use client'
  2. import React, { useEffect } from 'react'
  3. import cn from 'classnames'
  4. import EmbeddedChatbot from '@/app/components/base/chat/embedded-chatbot'
  5. import Loading from '@/app/components/base/loading'
  6. import { fetchSystemFeatures } from '@/service/share'
  7. import LogoSite from '@/app/components/base/logo/logo-site'
  8. const Chatbot = () => {
  9. const [isSSOEnforced, setIsSSOEnforced] = React.useState(true)
  10. const [loading, setLoading] = React.useState(true)
  11. useEffect(() => {
  12. fetchSystemFeatures().then((res) => {
  13. setIsSSOEnforced(res.sso_enforced_for_web)
  14. setLoading(false)
  15. })
  16. }, [])
  17. return (
  18. <>
  19. {
  20. loading
  21. ? (
  22. <div className="flex items-center justify-center h-full" >
  23. <div className={
  24. cn(
  25. 'flex flex-col items-center w-full grow items-center justify-center',
  26. 'px-6',
  27. 'md:px-[108px]',
  28. )
  29. }>
  30. <Loading type='area' />
  31. </div>
  32. </div >
  33. )
  34. : (
  35. <>
  36. {isSSOEnforced
  37. ? (
  38. <div className={cn(
  39. 'flex w-full min-h-screen',
  40. 'sm:p-4 lg:p-8',
  41. 'gap-x-20',
  42. 'justify-center lg:justify-start',
  43. )}>
  44. <div className={
  45. cn(
  46. 'flex w-full flex-col bg-white shadow rounded-2xl shrink-0',
  47. 'space-between',
  48. )
  49. }>
  50. <div className='flex items-center justify-between p-6 w-full'>
  51. <LogoSite />
  52. </div>
  53. <div className={
  54. cn(
  55. 'flex flex-col items-center w-full grow items-center justify-center',
  56. 'px-6',
  57. 'md:px-[108px]',
  58. )
  59. }>
  60. <div className='flex flex-col md:w-[400px]'>
  61. <div className="w-full mx-auto">
  62. <h2 className="text-[16px] font-bold text-gray-900">
  63. Warning: Chatbot is not available
  64. </h2>
  65. <p className="text-[16px] text-gray-600 mt-2">
  66. Because SSO is enforced. Please contact your administrator.
  67. </p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. )
  74. : <EmbeddedChatbot />
  75. }
  76. </>
  77. )}
  78. </>
  79. )
  80. }
  81. export default React.memo(Chatbot)